home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS04.ADF / text / printer.early < prev    next >
Text File  |  1985-11-03  |  75KB  |  2,097 lines

  1. /* printer.doc */
  2.  
  3. DISCLAIMER:
  4.  
  5.         This file is called printer.early in that  
  6.  
  7.         a.  it hasnt been reviewed.
  8.  
  9.         b.  the C language examples in this first part, the
  10.             tutorial, are adaptations from a file called
  11.             pio.c, also a part of this early output;  the
  12.             adaptations have not been tested and early users
  13.             should utilize pio.c routines in place of what 
  14.             is in this front section.
  15.  
  16.         c.  comments and questions are requested. 
  17.  
  18.         Rob Peck
  19.         10/30/85
  20.  
  21.  
  22.  
  23.  
  24. Printer Device
  25.  
  26.  
  27. INTRODUCTION
  28.  
  29. There are four basic ways of doing output to a printer on the Amiga 
  30. computer.  The features and advantages of each are listed below:
  31.  
  32. PRT:    
  33.  
  34.         This is the printer device.  By setting your user preferences 
  35.         you can direct the output to either a serial or parallel printer.  
  36.         This is, in effect, the generic printer configured on the system.  
  37.         You may print (output) escape sequences to PRT: to specify the 
  38.         options you want.  The escape sequences you send it are interpreted 
  39.         by the printer driver and (possibly different) escape sequences are 
  40.         forwarded to the printer.  The is by far the easiest method for most 
  41.         applications.  "PRT:" may be opened just like anyother AmigaDOS file.
  42.  
  43. SER:    
  44.  
  45.         This is the serial device.  If you "know" that the printer is 
  46.         connected to the serial port (you shouldn't) and you "know" 
  47.         what kind of printer it is (again, you shouldn't) then you
  48.         could use AmigaDOS to open "SER:" and output characters to it, 
  49.         causing it to print.  THIS BEHAVIOR IS STRONGLY DISCOURAGED!  
  50.         Characters you send are not examined or converted.
  51.  
  52. PAR:    
  53.  
  54.         This is the parallel device.  Same warnings as SER: apply.
  55.                 
  56. printer.device
  57.  
  58.         By opening the printer.device directly, you have full control 
  59.         over the printer.  You can either send escape sequences as shown 
  60.         in the command definitions table below for printer control, or 
  61.         call the RawWrite routine to send raw characters directly to your 
  62.         printer with no processing at all.  Using this technique would be 
  63.         similar to sending raw characters to SER: or PAR: from AmigaDOS, 
  64.         (but you don't need to know which one has the printer connected.)
  65.                 
  66.  
  67.  
  68. PRINTER DEVICE OUTPUT
  69.  
  70. The printer device can be thought of as kind of a filter, in that some 
  71. printers respond in one way to a command output and some respond in 
  72. another.  The printer device, as a generic printer, recognizes command
  73. sequences and, depending on the printer-dependent configuration that is
  74. currently loaded (by the Preferences tool), either ignores them or 
  75. perhaps translates them into an entirely different sequence that this
  76. printer can actually understand and obey.  
  77.  
  78. This chapter deals with these basic topics:
  79.  
  80. o  Setting up for printer I/O (creating an I/O request structure)
  81.  
  82. o  Writing to the printer to control its behavior
  83.  
  84. o  Writing characters or causing a graphics dump to a graphics capable printer
  85.  
  86. o  Closing the printer device.
  87.  
  88. o  An advanced topic section that covers creating your own printer device
  89.    driver.
  90.  
  91.  
  92. This section shows you how to set up for printer I/O.
  93.  
  94.  
  95. CREATING AN I/O REQUEST
  96.  
  97. Printer I/O, like other devices, requires that you create an I/O request
  98. message that you pass to the printer device for processing.  The message
  99. contains the command, as well as a data area.  In the data area, for a
  100. write, will be a pointer to the stream of information you wish to write
  101. to the printer. 
  102.  
  103. Here is a program fragment that can be used to create the message block
  104. that you use for printer communications.
  105.  
  106. For communicating with the printer:
  107.  
  108.         struct IOStdReq *printerMsg;   /* I/O request block pointer */
  109.         struct Port *printerPort;      /* a port at which to receive */
  110.         
  111.         printerPort = CreatePort("print.port",0);
  112.         if(printerPort == 0) exit(100); /* error in createport */
  113.         printerMsg =  CreatePrinterIO(printerPort);
  114.         if(printerMsg == 0) exit(200); /* error in createprinterio */
  115.  
  116. The routine CreatePort is part of amiga.lib. 
  117.  
  118. Note that there are two additional kinds of I/O request blocks that, for
  119. some commands, must be prepared for sending to the printer.  The first
  120. is called IODRPReq, and the second is called IOPrtCmdReq.  Both are
  121. outlined in the include-file "devices/printer.h".  A routine called
  122. CreatePrinterIO() is included at the back of this chapter and can be
  123. utilized to allocate memory for such structures.  It corresponds to
  124. CreateStdIO for creating a pointer to a message-passing data structure.
  125. A routine named DeletePrinterIO() is provided as well, to deallocate
  126. the memory that CreatePrinterIO() allocated.
  127.  
  128.  
  129.  
  130. OPENING A PRINTER DEVICE
  131.  
  132. To open a path to the printer device, you open it using a routine such
  133. as the following:
  134.  
  135.         int
  136.         OpenPrinter(request)
  137.         printerIO *request;
  138.         {
  139.         return(OpenDevice("printer.device",0,request,0));
  140.         }
  141.  
  142. This routine returns a value of zero if the printer device was opened
  143. successfully and a value other than zero if it did not open.
  144.  
  145. Note that the data structure type "printerIO" is a C-language union defined
  146. as:
  147.  
  148.                 union {
  149.                 struct IOStdReq ios;
  150.                 struct IODRPReq iodrp;
  151.                 struct IOPrtCmdReq iopc;
  152.                 } printerIO;
  153.  
  154. This means that one memory area can be used to represent three distinct
  155. forms of memory layout, for the three different types of data structures
  156. that must be used to pass commands to the printer device.  Some of the
  157. commands are simple, and can use an IOStdReq.  Some of the commands
  158. require many more parameters and extend the basic I/O request block
  159. accordingly.
  160.  
  161.  
  162. WRITING TO THE PRINTER
  163.  
  164. There are three forms involved in  writing to the printer.  The first uses 
  165. a character stream that you create, possibly containing escape sequences to 
  166. be processed by the printer driver (PrinterWrite example) or containing 
  167. just about anything else that is to be passed directly to the printer 
  168. (PrinterRaw example).   The second form of write passes a command to the 
  169. printer(PrinterCmd example).  The third form asks for a graphics dump of 
  170. a drawing area (PrinterDump example). 
  171.  
  172.  
  173. To write to the printer, you pass to the printer device the system standard
  174. command CMD_WRITE.  Here are routines that can be used to send this command.
  175.  
  176.         /* Send a NULL terminated string to the printer */
  177.         /* Assumes printer device is open and printerMsg 
  178.          * is correctly initialized.  Watches for embedded
  179.          * "escape-sequences" and handles them as defined.
  180.          */
  181. int
  182. PrinterWrite(request,string)
  183. char *string;
  184. printerIO *request;
  185. {
  186.     int count;
  187.     char *b;
  188.  
  189.     s = string;
  190.     count = 0;
  191.     while (*s++ != '\0') count++;
  192.     /* queue a printer write */
  193.     request->ios.io_Command = CMD_WRITE;
  194.     request->ios.io_Data = buffer;
  195.     request->ios.io_Length = count;
  196.     return(DoIO(request));
  197. }
  198.  
  199.         /* Send RAW character stream to the printer directly, 
  200.          * avoid "escape-sequence" parsing by the device.
  201.          * Also a NULL terminated stream.
  202.          */
  203.  
  204. int
  205. PrintRaw(request,buffer) 
  206. char *buffer;
  207. printerIO *request;
  208. {
  209.     int count;
  210.     char *b;
  211.  
  212.     b = buffer;
  213.     count = 0;
  214.     while (*b++ != '\0') count++;
  215.     /* queue a printer raw write */
  216.     request->ios.io_Command = PRD_RAWWRITE;
  217.     request->ios.io_Data = buffer;
  218.     request->ios.io_Length = count;
  219.     return(DoIO(request));
  220. }
  221.  
  222.  
  223.  
  224.  
  225. Printer Command Definitions
  226.  
  227. The following table describes the supported printer functions.
  228. You can use the escape sequences with PRT: and the printer.device.
  229. In order to use the Name or command numbers you need to open the
  230. printer.library directly.  
  231.  
  232. Again, recall that SER: and PAR: will ignore all of these and pass
  233. them directly on to the attached device.
  234.  
  235.  
  236.         Cmd Escape                          Defined
  237. Name    No. sequence    Function              by:
  238. ------- --- --------    ------------------- -------
  239. aRIS     0  ESCc        reset                ISO
  240. aRIN     1  ESC#1       initialize           +++
  241. aIND     2  ESCD        lf                   ISO               
  242. aNEL     3  ESCE        return,lf            ISO         
  243. aRI      4  ESCM        reverse lf           ISO      
  244.  
  245. aSGR0    5  ESC[0m      normal char set      ISO    
  246. aSGR3    6  ESC[3m      italics on           ISO        
  247. aSGR23   7  ESC[23m     italics off          ISO
  248. aSGR4    8  ESC[4m      underline on         ISO
  249. aSGR24   9  ESC[24m     underline off        ISO
  250. aSGR1   10  ESC[1m      boldface on          ISO
  251. aSGR22  11  ESC[22m     boldface off         ISO
  252. aSFC    12  ESC[30m     set foreground color ISO
  253.                         (range is 30-39)
  254. aSBC    13  ESC[40m     set background color ISO
  255.                         (range is 40-49)
  256.  
  257. aSHORP0 14  ESC[0w      normal pitch         DEC
  258. aSHORP2 15  ESC[2w      elite on             DEC
  259. aSHORP1 16  ESC[1w      elite off            DEC
  260. aSHORP4 17  ESC[4w      condensed fine on    DEC
  261. aSHORP3 18  ESC[3w      condensed off        DEC
  262. aSHORP6 19  ESC[6w      enlarged on          DEC
  263. aSHORP5 20  ESC[5w      enlarged off         DEC
  264.  
  265. aDEN6   21  ESC[6"z     shadow print on      DEC (sort of)
  266. aDEN5   22  ESC[5"z     shadow print off     DEC
  267. aDEN4   23  ESC[4"z     doublestrike on      DEC
  268. aDEN3   24  ESC[3"z     doublestrike off     DEC
  269. aDEN2   25  ESC[2"z     NLQ on               DEC
  270. aDEN1   26  ESC[1"z     NLQ off              DEC
  271.  
  272. aSUS2   27  ESC[2v      superscript on       +++
  273. aSUS1   28  ESC[1v      superscript off      +++
  274. aSUS4   29  ESC[4v      subscript on         +++
  275. aSUS3   30  ESC[3v      subscript off        +++
  276. aSUS0   31  ESC[0v      normalize the line   +++
  277. aPLU    32  ESCL        partial line up      ISO
  278. aPLD    33  ESCK        partial line down    ISO
  279.  
  280. aFNT0   34  ESC(B       US char set          DEC
  281. aFNT1   35  ESC(R       French char set      DEC
  282. aFNT2   36  ESC(K       German char set      DEC
  283. aFNT3   37  ESC(A       UK char set          DEC
  284. aFNT4   38  ESC(E       Danish I char set    DEC
  285. aFNT5   39  ESC(H       Swedish char set     DEC
  286. aFNT6   40  ESC(Y       Italian char set     DEC
  287. aFNT7   41  ESC(Z       Spanish char set     DEC
  288. aFNT8   42  ESC(J       Japanese char set    +++
  289. aFNT9   43  ESC(6       Norweign char set    DEC
  290. aFNT10  44  ESC(C       Danish II char set   +++
  291.                    
  292. aPROP2  45  ESC[2p      proportional on      +++
  293. aPROP1  46  ESC[1p      proportional off     +++
  294. aPROP0  47  ESC[0p      proportional clear   +++
  295. aTSS    48  ESC[n E     set proportional offset  ISO
  296. aJFY5   49  ESC[5 F     auto left justify    ISO
  297. aJFY7   50  ESC[7 F     auto right justify   ISO
  298. aJFY6   51  ESC[6 F     auto full justify    ISO
  299. aJFY0   52  ESC[0 F     auto justify off     ISO
  300. aJFY3   53  ESC[3 F     letter space (justify)   ISO (special)
  301. aJFY1   54  ESC[1 F     word fill(auto center)   ISO (special)
  302.  
  303. aVERP0  55  ESC[0z      1/8" line spacing    +++
  304. aVERP1  56  ESC[1z      1/6" line spacing    +++
  305. aSLPP   57  ESC[nt      set form length n    DEC
  306. aPERF   58  ESC[nq      perf skip n (n>0)    +++
  307. aPERF0  59  ESC[0q      perf skip off        +++
  308.              
  309. aLMS    60  ESC#9       Left margin set      +++
  310. aRMS    61  ESC#0       Right margin set     +++
  311. aTMS    62  ESC#8       Top margin set       +++
  312. aBMS    63  ESC#2       Bottom marg set      +++
  313. aSTBM   64  ESC[n1;n2r  T&B margins        DEC
  314. aSLRM   65  ESC[n1;n2s  L&R margin         DEC
  315. aCAM    66  ESC#3       Clear margins        +++
  316.  
  317. aHTS    67  ESCH        Set horiz tab        ISO
  318. aVTS    68  ESCJ        Set vertical tabs    ISO
  319. aTBC0   69  ESC[0g      Clr horiz tab        ISO
  320. aTBC3   70  ESC[3g      Clear all h tab      ISO
  321. aTBC1   71  ESC[1g      Clr vertical tabs    ISO
  322. aTBC4   72  ESC[4g      Clr all v tabs       ISO
  323. aTBCALL 73  ESC#4       Clr all h & v tabs   +++
  324. aTBSALL 74  ESC#5       Set default tabs     +++
  325. aEXTEND 75  ESC[n"x     extended commands    +++
  326.  
  327.  
  328. Legend:
  329. -------
  330.  
  331.         ISO indicates that the sequence has been defined by the 
  332.                 International Standards Organization.  This is
  333.                 also very similar to ANSII x3.64
  334.  
  335.         DEC indicates a control sequence defined by Digital 
  336.                 Equipment Corperation.
  337.         
  338.         +++ indicates a sequence unique to Amiga.
  339.  
  340.         n   in the table above, a lower case n stands for a decimal
  341.             number, expressed as a set of ascii digits, for example
  342.             "12".
  343.  
  344.  
  345. ADVANCED SECTION - CREATING A PRINTER DRIVER
  346.  
  347. Creating a printer dependent code fragment for the printer device involves
  348. writing the data structures and code needed, compiling and assembling it, and
  349. linking it to produce an amiga object binary file such that the first hunk in
  350. that file is the PrinterSegment structure described in devices/prtbase.[hi]
  351. (which is pointed to by the BPTR returned by the LoadSeg of the object file).
  352. The user specifies the printer dependent object file to load by specifying
  353. Custom printer in preferences, and filling in the Custom Printer Name with the
  354. name of the object file (relative to the directory DEVS:printers/).
  355.  
  356. The printer dependent code PrinterSegment contains the PrinterExtendedData
  357. (PED) structure (also described in devices/prtbase.[hi]) at the beginning of
  358. the object.  The PED structure contains data describing the capabilities of the
  359. printer, as well as pointers to code and other data.  Here is the assembly code
  360. for a sample PrinterSegment, which would be linked to the beginning of the
  361. sequence of files describing the printer dependent code fragment.
  362.  
  363.     **********************************************************************
  364.     *
  365.     *   printer device dependent code tag
  366.     *
  367.     **********************************************************************
  368.  
  369.             ; named sections are easier to exactly place in the linked file
  370.             SECTION             custom
  371.  
  372.     *------ Included Files -----------------------------------------------
  373.  
  374.             INCLUDE             "exec/types.i"
  375.             INCLUDE             "exec/nodes.i"
  376.  
  377.             INCLUDE             "revision.i"    ; contains VERSION & REVISION
  378.  
  379.             INCLUDE             "devices/prtbase.i"
  380.  
  381.  
  382.     *------ Imported Names -----------------------------------------------
  383.  
  384.             XREF                _Init
  385.             XREF                _Expunge
  386.             XREF                _Open
  387.             XREF                _Close
  388.             XREF                _CommandTable
  389.             XREF                _DoSpecial
  390.             XREF                _Render
  391.  
  392.     *------ Exported Names -----------------------------------------------
  393.  
  394.             XDEF                _PEDData
  395.  
  396.  
  397.     **********************************************************************
  398.  
  399.                     ; in case anyone tries to execute this
  400.                     MOVEQ       #0,D0
  401.                     RTS
  402.  
  403.                     DC.W        VERSION
  404.                     DC.W        REVISION
  405.     _PEDData:
  406.                     DC.L        printerName
  407.                     DC.L        _Init
  408.                     DC.L        _Expunge
  409.                     DC.L        _Open
  410.                     DC.L        _Close
  411.                     DC.B        PPC_BWGFX       ; PrinterClass
  412.                     DC.B        PCC_BW          ; ColorClass
  413.                     DC.B        80              ; MaxColumns
  414.                     DC.B        1               ; NumCharSets
  415.                     DC.W        8               ; NumRows
  416.                     DC.L        960             ; MaxXDots
  417.                     DC.L        0               ; MaxYDots
  418.                     DC.W        120             ; XDotsInch
  419.                     DC.W        82              ; YDotsInch
  420.                     DC.L        _CommandTable   ; Command Strings
  421.                     DC.L        _DoSpecial      ; Command Code
  422.                     DC.L        _Render         ; Graphics Render
  423.                     DC.L        30              ; Timeout
  424.  
  425.     printerName:
  426.                     DC.B        'Custom Printer Name'
  427.                     DC.B        0
  428.                     EVEN
  429.  
  430.  
  431. The printer name should be the brand name of the printer that is available for
  432. use by programs wishing to be specific about the printer name in any diagnostic
  433. or instruction messages.  The four functions at the top of the structure are
  434. used to initialize this printer depentent code:
  435.     (*(PED->ped_Init))(PD);
  436.         is called when the printer dependent code is loaded, and provides a
  437.         pointer to the printer device for use by the printer dependent code.
  438.         It can also be used to open up any libraries or devices needed by the
  439.         printer dependent code.
  440.     (*(PED->ped_Expunge))();
  441.         is called immediately before the printer dependent code is unloaded, to
  442.         allow it to close any resources obtained at initialization time.
  443.     (*(PED->ped_Open))(ior);
  444.         is called in the process of an OpenDevice call, after the preferences
  445.         are read and the correct primitive IO device (parallel or serial) is
  446.         opened.  It must return zero if the open is successful, or non-zero to
  447.         terminate the open and return an error to the user.
  448.     (*(PED->ped_Close))(ior);
  449.         is called in the process of a CloseDevice call, to allow the printer
  450.         dependent code to close any resources obtained at open time.
  451.  
  452. The PD variable provided as a parameter to the initialization call is a pointer
  453. to the PrinterData structure described in devices/prtbase.[hi].  This is also
  454. the same as the io_Device entry in printer IO requests.
  455.     pd_SegmentData
  456.         points back to the PrinterSegment, which contains the PED.
  457.     pd_PrintBuf
  458.         is available for use by the printer dependent code -- it is not
  459.         otherwise used by the printer device.
  460.     (*pd_PWrite)(data, length);
  461.         is the interface routine to the primitive IO device.  This routine uses
  462.         two IO requests to the primitive device, so writes are double-buffered.
  463.         The data parameter points to the byte data to send, and the length is
  464.         the number of bytes.
  465.     (*pd_PBothReady)();
  466.         waits for both primitive IO requests to complete.  This is useful if
  467.         your code does not want to use double buffering -- if you want to use
  468.         the same data buffer for successive pd_PWrites, you must seperate them
  469.         with a call to this routine.
  470.     pd_Preferences
  471.         is the copy of preferences in use by the printer device, obtained when
  472.         the printer was opened.
  473.  
  474.  
  475. The timeout field is the number of seconds that an I/O request from the printer
  476. device will remain posted and unsatisfied to the primitive IO device (parallel
  477. or serial) before the timeout requestor is presented to the user.  This value
  478. should be large enough to avoid the requestor during normal printing.
  479.  
  480.  
  481. The developer's document for how to write a graphics printer driver
  482. includes files called render.c and printertag.asm.  These are files
  483. you create for a custom printer driver.  Four files for four different
  484. types of printers are contained in this document, for the following:
  485.  
  486.  
  487. diablo_c - an example of a ymcb color printer
  488. epson - an example of a b/w printer
  489. okimate20 - an example of a ymc_bw printer (has two render,c functions)
  490. hpplus - an example of a single sheet multiple density printer
  491.  
  492.  
  493.    Writing a Custom Graphics Printer Driver for the AMIGA
  494.    ------------------------------------------------------
  495.  
  496.    Designing a custom graphics printer driver consists of 2 steps;
  497. writing a specific render.c function, and replacing the printer specific
  498. values in printertag.asm.
  499.  
  500. RENDER.C
  501. --------
  502.    This function is the main printer specific code module and consists of
  503. 6 parts; (0)master initialization, (1)pixel rendering, (2)dumping a pixel buffer
  504. to the printer, (3)clearing and initializing the pixel buffer, (4)closing down,
  505. and (5)density selection.
  506.  
  507. 1. Master Initialization (case 0)
  508.    When this call is made you must use PC to define values for ROWSIZE,
  509. COLORSIZE(only on color printers), BUFSIZE, and colors[] (only on color
  510. printers). PC is the maximum number of Print Columns or pixels per row
  511. that the dump program is going to send to you. Note that the
  512. graphic driver uses double buffering, that is why the
  513. AllocMem call allocs BUFSIZE*2 ubytes. You are also expected to reset
  514. the printer and any other initial initialization required.
  515.  
  516. 2. Render Pixel (case 1)
  517.    When this call is made, you will be passed the x,y position of the pixel
  518. and its color type. You are expected to put the pixel in the proper place
  519. in the buffer. The color types are; 0-black, 1-yellow, 2-magenta, and
  520. 3-cyan.
  521.  
  522. 3. Dump Buffer to Printer (case 2)
  523.    When this call is made, you must send the buffer to the printer. AS IT NOW
  524. STANDS, YOU SHOULD NEVER NEED TO CHANGE THIS ROUTINE. IT SHOULD BE COMMON TO
  525. ALL PRINTERS, IT S      MPLY SENDS THE BUFFER THAT YOU HAVE BEEN FILLING (VIA
  526. CASE 1) TO THE PRINTER.
  527.  
  528. 4. Clear and Init the Buffer (case 3)
  529.    This consists of two parts, clearing the buffer and initing the buffer.
  530. Clearing the buffer should be the same for all printers. Initing the
  531. buffer is printer specific and it includes placing the printer specific
  532. control code in the buffer ahead and behind of where the data will go.
  533.  
  534. 5. Closing Down (case 4)
  535.    When this call is made you must wait for the print buffers to clear and
  536. then de-allocate the memory. AS IT NOW STANDS, YOU SHOULD NEVER NEED TO
  537. CHANGE THIS ROUTINE. IT SHOULD BE COMMON TO ALL PRINTERS, IT SIMPLY WAITS
  538. FOR BOTH BUFFERS TO EMPTY AND THEN DE-ALLOCATES THE MEMORY.
  539.  
  540. 6. Density Selection (case 5)
  541.    Currently this option is implemented only on the HPLaserJet and
  542. HPLaserJet PLUS printer(s), although the call is made to each printer
  543. specific driver. Ignoring it causes no problems as the call is made simply
  544. to give you a chance to select a different density from the default one.
  545. You should note that this call is
  546. made BEFORE the master initialization call and gives you a chance to alter
  547. any variables which the MI may use to program the printer.
  548.  
  549.  
  550. PRINTERTAG.ASM
  551. --------------
  552.    The printer specific values that need to be filled in here are:
  553. 1. MaxXDots - the maximum # of dots the printer can print across the page.
  554. 2. MaxYDots - the maximum # of dots the printer can print down the page.
  555.    Generally, if the printer supports roll or form feed paper then this
  556. value should be 0 indicating that there is no limit. If the printer has a
  557. definte y dots maximum (as the HPLaserJet) then this number should be
  558. entered here.
  559. 3. XDotsInch - the dot density in x (ie. 120 dpi).
  560. 4. YDotsInch - the dot density in y (ie. 144 dpi).
  561. 5. PrinterClass - the printer class the printer falls into.
  562.    Current choices are:
  563.       PPC_BWALPHA - alphanumeric, no graphics.
  564.       PPC_BWGFX - black&white (only) graphics.
  565.       PPC_COLORGFX - color (and maybe b/w) graphics.
  566. 6. ColorClass - the color class the printer falls into.
  567.    Current choices are:
  568.       PCC_BW - Black&White only.
  569.       PCC_YMC - Yellow Magenta Cyan only.
  570.       PCC_YMC_BW -  "  or Black&White but not both (like the Okimate 20).
  571.       PCC_YMCB - YellowMagentaCyanBlack.
  572.  
  573.  
  574.  
  575.  
  576. Below is a description of the alpha section.  It is meant to
  577. be read with the alpha listing for the EpsonX80 and Diablo Adv 25
  578. close at hand.
  579.  
  580.  
  581. The alphanumeric portion of the printer driver is designed to convert
  582. ANSI x3.64 style commands into the specific escape codes required by
  583. each individual printer.  For example, the ANSI code for italics on
  584. is ESC[3m  .  The Epson FX80 printer would like a ESC%G to turn italics
  585. italics, while the Diablo Advantage D25 might like something different.
  586. By using the printer driver all printers may be handled in a similar manner.
  587.  
  588.  
  589. There are two parts to the alphanumeric portion of the printer driver:
  590. The CommandTable data table, and the DoSpecial() routine.  
  591.  
  592. The CommandTable is used to convert all escape codes which can be handled by
  593. simple substitution.  There is one entry per ANSI command supported.  The
  594. order of the commands is given in the printer.h file. By placing the specific
  595. codes for your printer in the proper position, the conversion takes place
  596. automatically.  
  597.  
  598. NOTE: if the code for your printer requires a decimal 0 (an ASCII NUL 
  599. character) , this is entered into the Command Table as an octal 376 (decimal 
  600. 254).
  601.  
  602. Placing an octal value of 377 (255 decimal) in a position in the command
  603. table indicates to the printer device that no simple conversion is available
  604. on this printer for this ANSI command.  For example,  if a printer does not 
  605. support one of the functions (i.e. if a daisy wheel printer does not have a f
  606. oreign character set), 377 octal (255 decimal) is placed in that position.  
  607. However, 377 in a position can also mean that the ANSI function is to be
  608. handled by code located in the DOSPECIAL function.
  609.  
  610. The DoSpecial function is meant to implement all the ANSI functions
  611. which can't be done by simple conversion, but which the printer
  612. is capable of.  These are functions which need parameter conversion,
  613. read values from preferences, etc.
  614.  
  615. The DoSpecial function is set up as follows:
  616.  
  617. #include        "exec/types.h"
  618. #include "../printer/printer.h"
  619. #include "../printer/prtbase.h"
  620.  
  621. extern struct PrinterData *PD;
  622.  
  623. DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
  624.    char outputBuffer[];
  625.    UWORD *command;
  626.    BYTE *vline;
  627.    BYTE *currentVMI;
  628.    BYTE *crlfFlag;
  629.    UBYTE Parms[];
  630. {
  631.  
  632. The command number will be in *command.  The file printer.h contains
  633. the definitions for the routines to use (i.e. aRIN is initialize, etc.)
  634.  
  635. The current line position will be in vline.
  636.  
  637. the current line spacing will in currentVMI.
  638.  
  639. crlfFlag contains the setting of the 'Add line feed after carriage return 
  640. flag'
  641.  
  642. Parms contain whatever parameters were given with the ANSI command.
  643.  
  644. outputBuffer is the buffer where the converted command is returned.
  645. flag.
  646.  
  647. Parms contain whatever parameters were given with the ANSI command.
  648.  
  649. outputBuffer is the buffer where the converted command is returned.
  650.  
  651. Almost every printer will require a aRIN (initialize) command in DoSpecial.
  652. This command reads the printer settings from preferences, and makes
  653. the proper control sequence for the specific printer.  Also, it returns
  654. the character set to normal (not italicized, not bold, etc).
  655.  
  656. Other functions depend on the printer.
  657.  
  658. Certain functions are implemented both in the CommandTable and the
  659. DoSpecial routine.  Those are functions like superscript, subscript,
  660. PLU (partial line up) and PLD (partial line down) which can often
  661. be handled by a simple conversion, but must adjust the printer
  662. devices line position variable.
  663.  
  664.  
  665. FOLLOWING IS ORIGINAL FILE BEING ADAPTED PER INFORMATION IN DISCLAIMER.
  666. PRIMARY REASON FOR ADAPTATION IS CONSISTENCY IN APPROACH WITH REST OF
  667. REWRITE OF ROM KERNEL MANUAL.
  668.  
  669.  
  670. /*********************************************************************/
  671. /*                                                                   */
  672. /*                     Copyright (c) 1985                            */
  673. /*                    Commodore-Amiga, Inc.                          */
  674. /*                    All rights reserved.                           */
  675. /*                                                                   */
  676. /*     No part of this program may be reproduced, transmitted,       */
  677. /*     transcribed, stored in retrieval system, or translated        */
  678. /*     into any language or computer language, in any form or        */
  679. /*     by any means, electronic, mechanical, magnetic, optical,      */
  680. /*     chemical, manual or otherwise, without the prior written      */
  681. /*     permission of:                                                */
  682. /*                     Commodore-Amiga, Inc.                         */
  683. /*                     983 University Ave #D                         */
  684. /*                     Los Gatos, CA. 95030                          */
  685. /*                                                                   */
  686. /*********************************************************************/
  687.  
  688. #include        "exec/types.h"
  689. #include        "exec/nodes.h"
  690. #include        "exec/lists.h"
  691. #include        "exec/ports.h"
  692. #include        "exec/tasks.h"
  693. #include        "exec/io.h"
  694. #include        "devices/printer.h"
  695.  
  696. union {
  697.     struct IOStdReq ios;
  698.     struct IODRPReq iodrp;
  699.     struct IOPrtCmdReq iopc;
  700. } printerIO;
  701.  
  702. struct MsgPort replyMsgPort;
  703.  
  704. int pOpen(signal) /* open the printer */
  705. int signal;
  706. {
  707.     int error;
  708.             
  709.     if ((error = OpenDevice("printer.device", 0, &printerIO, 0)) != 0)
  710.         return(error);
  711.  
  712.     /* set up the message port in the I/O request */
  713.     replyMsgPort.mp_Node.ln_Type = NT_MSGPORT;
  714.     replyMsgPort.mp_Node.ln_Name = "PIO";
  715.     replyMsgPort.mp_Flags = 0;
  716.     replyMsgPort.mp_SigBit = signal;
  717.     replyMsgPort.mp_SigTask = (struct Task *) FindTask((char *) NULL);
  718.     AddPort(&replyMsgPort);
  719.  
  720.     printerIO.ios.io_Message.mn_ReplyPort = &replyMsgPort;
  721.     return(0);
  722. }
  723.  
  724. pClose() /* close the printer */
  725. {
  726.     CloseDevice(&printerIO);
  727.     RemPort(&replyMsgPort);
  728. }
  729.  
  730. int
  731. pDumpRPort(rastPort, colorMap, modes, sx,sy, sw,sh, dc,dr, s)
  732. struct RastPort *rastPort;
  733. struct ColorMap *colorMap;
  734. ULONG modes;
  735. UWORD sx, sy, sw, sh;
  736. LONG dc, dr;
  737. UWORD s;
  738. {
  739.     printerIO.iodrp.io_Command = PRD_DUMPRPORT;
  740.     printerIO.iodrp.io_RastPort = rastPort;
  741.     printerIO.iodrp.io_ColorMap = colorMap;
  742.     printerIO.iodrp.io_Modes = modes;
  743.     printerIO.iodrp.io_SrcX = sx;
  744.     printerIO.iodrp.io_SrcY = sy;
  745.     printerIO.iodrp.io_SrcWidth = sw;
  746.     printerIO.iodrp.io_SrcHeight = sh;
  747.     printerIO.iodrp.io_DestCols = dc;
  748.     printerIO.iodrp.io_DestRows = dr;
  749.     printerIO.iodrp.io_Special = s;
  750.     return(DoIO(&printerIO));
  751. }
  752.  
  753. int
  754. pWrite(buffer) /* write to the printer */
  755. char *buffer;
  756. {
  757.     int count;
  758.     char *b;
  759.  
  760.     b = buffer;
  761.     count = 0;
  762.     while (*b++ != '\0') count++;
  763.     /* queue a printer write */
  764.     printerIO.ios.io_Command = CMD_WRITE;
  765.     printerIO.ios.io_Data = buffer;
  766.     printerIO.ios.io_Length = count;
  767.     return(DoIO(&printerIO));
  768. }
  769.  
  770. int
  771. pRawWrite(buffer) /* write to the printer w/o escape parsing */
  772. char *buffer;
  773. {
  774.     int count;
  775.     char *b;
  776.  
  777.     b = buffer;
  778.     count = 0;
  779.     while (*b++ != '\0') count++;
  780.     /* queue a printer raw write */
  781.     printerIO.ios.io_Command = PRD_RAWWRITE;
  782.     printerIO.ios.io_Data = buffer;
  783.     printerIO.ios.io_Length = count;
  784.     return(DoIO(&printerIO));
  785. }
  786.  
  787. pPrtCommand(command, p0, p1, p2, p3) /* perform a printer command */
  788. int command, p0, p1, p2, p3;
  789. {
  790.     /* queue a printer command */
  791.     printerIO.iopc.io_Command = PRD_PRTCOMMAND;
  792.     printerIO.iopc.io_PrtCommand = command;
  793.     printerIO.iopc.io_Parm0 = p0;
  794.     printerIO.iopc.io_Parm1 = p1;
  795.     printerIO.iopc.io_Parm2 = p2;
  796.     printerIO.iopc.io_Parm3 = p3;
  797.     return(DoIO(&printerIO));
  798. }
  799.  
  800.  
  801.  
  802. FOLLOWING ARE THE RENDER.C FILES AND PRINTERTAG.ASM FILES REFERENCED ABOVE:
  803.  
  804.  
  805. /*********************************************************************/
  806. #include <exec/types.h>
  807. #include <exec/nodes.h>
  808. #include <exec/lists.h>
  809. #include <exec/memory.h>
  810. #include "../printer/prtbase.h"
  811.  
  812. extern struct PrinterData *PD;
  813.  
  814. /* for the DIABLO C-150 */
  815. int Render(ct, x, y, status, pc)    /* passed a color type */
  816.     UBYTE ct;               /* the color type to use (0, 1, 2 or 3) */
  817.     UWORD x, y;             /* the x & y co-ordinates */
  818.     UBYTE status;           /* print status (0-init, 1-enter pixel, 2-dump) */
  819.     UWORD pc;               /* the # of print columns (ie. pixels) */
  820. {
  821.     static UWORD ROWSIZE;
  822.     static UWORD COLORSIZE;
  823.     static UWORD BUFSIZE;
  824.     static UWORD colors[4]; /* color ptrs */
  825.     static BYTE huns,tens,ones; /* used to program buffer size */
  826.     static UWORD bufptr; /* used for double buffering; points to buffer 1 or 2 */
  827.     UWORD i;                    /* mics. var */
  828.     BYTE err;               /* the error # */
  829.  
  830.     switch(status)
  831.     {
  832.     case 0 :    /* alloc memory for printer buffer (uses double buffering) */
  833.         ROWSIZE=(pc+7)/8; /* pc/8 pixels per row on the DIABLO C-150 */
  834.         huns=ROWSIZE/100;
  835.         tens=(ROWSIZE-huns*100)/10;
  836.         ones=(ROWSIZE-huns*100-tens*10);
  837.         ROWSIZE += 7; /* plus 7 cmd bytes */
  838.         COLORSIZE=(ROWSIZE*4); /*the size of each color buffer */
  839.         BUFSIZE=(COLORSIZE*4+3); /* buffer size required for DIABLO C-150 */
  840.         colors[0] = 7; /* black */
  841.         colors[1] = COLORSIZE*2+7; /* yellow */
  842.         colors[2] = COLORSIZE+7; /* magenta */
  843.         colors[3] = COLORSIZE*3+7; /* cyan */
  844.         PD->pd_PrintBuf = (UBYTE *)
  845.             AllocMem(BUFSIZE*2,MEMF_PUBLIC); /* alloc public mem */
  846.         if (err=(PD->pd_PrintBuf==0)) return(err);
  847.         if (err=(*(PD->pd_PWrite))("\033\rP",3)) return(err); /* reset printer to power-up */
  848.         if (err=(*(PD->pd_PWrite))("\033l5\r",4)) return(err); /* set l margin to .5 inch. */
  849.         if (err=(*(PD->pd_PWrite))("\033r90\r",5)) return(err); /* set r margin to 9 inch. */
  850.         bufptr=0; /* init to first buffer */
  851.         return(0); /* flag all ok */
  852.         break;
  853.  
  854.     case 1 :    /* put pixel in buffer */
  855.         i = bufptr+x/8+(y&3)*ROWSIZE+colors[ct]; /* calc which byte to use */
  856.         PD->pd_PrintBuf[i] = PD->pd_PrintBuf[i] | (1 << (7-(x&7))); /* fill print buffer */
  857.         return(0); /* flag all ok */
  858.         break;
  859.  
  860.     case 2 : /* dump buffer to printer */
  861.         if (err=(*(PD->pd_PWrite))(&(PD->pd_PrintBuf[bufptr]), BUFSIZE)) return(err);
  862.         bufptr=BUFSIZE-bufptr; /* switch to other buffer */
  863.         return(0); /* flag all ok */
  864.         break;
  865.  
  866.     case 3 : /* clear and init buffer */
  867.         for (i=bufptr; i<BUFSIZE+bufptr; i++)
  868.             PD->pd_PrintBuf[i] = 0; /* clear buffer */
  869.         for (i=0; i<16; i++) {
  870.             PD->pd_PrintBuf[bufptr+i*ROWSIZE] = 27;
  871.             PD->pd_PrintBuf[bufptr+i*ROWSIZE+1] = 'g';
  872.             PD->pd_PrintBuf[bufptr+i*ROWSIZE+2] = i+'0';
  873.             PD->pd_PrintBuf[bufptr+i*ROWSIZE+3] = huns + '0';
  874.             PD->pd_PrintBuf[bufptr+i*ROWSIZE+4] = tens + '0';
  875.             PD->pd_PrintBuf[bufptr+i*ROWSIZE+5] = ones + '0';
  876.             PD->pd_PrintBuf[bufptr+i*ROWSIZE+6] = ','; /* select # of bytes for each line */
  877.         }
  878.         PD->pd_PrintBuf[bufptr+BUFSIZE-3] = 27;
  879.         PD->pd_PrintBuf[bufptr+BUFSIZE-2] = 'k';
  880.         PD->pd_PrintBuf[bufptr+BUFSIZE-1] = '1';
  881.         return(0); /* flag all ok */
  882.         break;
  883.  
  884.     case 4 : /* free the print buffer memory */
  885.         err=(*(PD->pd_PBothReady))(); /* wait for both buffers to be clear */
  886.         FreeMem(PD->pd_PrintBuf,BUFSIZE*2); /* free the print buffers memory */
  887.         return(err); /* return status */
  888.         break;
  889.  
  890.     default : return(0); /* flag all ok */
  891.     }
  892. }
  893.  
  894.  
  895.         TTL    '$Header: printertag.asm,v 1.2 85/10/09 23:57:10 kodiak Exp $'
  896. **********************************************************************
  897. *                                                                    *
  898. *   Copyright 1985, Commodore-Amiga Inc.   All rights reserved.      *
  899. *   No part of this program may be reproduced, transmitted,          *
  900. *   transcribed, stored in retrieval system, or translated into      *
  901. *   any language or computer language, in any form or by any         *
  902. *   means, electronic, mechanical, magnetic, optical, chemical,      *
  903. *   manual or otherwise, without the prior written permission of     *
  904. *   Commodore-Amiga Incorporated, 983 University Ave. Building #D,   *
  905. *   Los Gatos, California, 95030                                     *
  906. *                                                                    *
  907. **********************************************************************
  908. *
  909. *       printer device dependent code tag
  910. *
  911. *   Source Control
  912. *   --------------
  913. *   $Header: printertag.asm,v 1.2 85/10/09 23:57:10 kodiak Exp $
  914. *
  915. *   $Locker:  $
  916. *
  917. *   $Log:       printertag.asm,v $
  918. *   Revision 1.2  85/10/09  23:57:10  kodiak
  919. *   replace reference to pdata w/ prtbase
  920. *   
  921. *   Revision 1.1  85/09/25  18:45:12  kodiak
  922. *   double timeout: alpha is too slow to print 400 chars in 30 sec.
  923. *   
  924. *   Revision 1.0  85/09/25  18:32:57  kodiak
  925. *   added to rcs for updating in version 1
  926. *   
  927. *   Revision 25.1  85/06/16  01:02:15  kodiak
  928. *   *** empty log message ***
  929. *   
  930. *   Revision 25.0  85/06/15  06:40:00  kodiak
  931. *   added to rcs
  932. *   
  933. *   Revision 25.0  85/06/13  18:53:36  kodiak
  934. *   added to rcs
  935. *   
  936. *
  937. **********************************************************************
  938.  
  939.         SECTION         printer
  940.  
  941. *------ Included Files -----------------------------------------------
  942.  
  943.         INCLUDE         "exec/types.i"
  944.         INCLUDE         "exec/nodes.i"
  945.         INCLUDE         "exec/strings.i"
  946.  
  947.         INCLUDE         "diablo_c_rev.i"
  948.  
  949.         INCLUDE         "../printer/prtbase.i"
  950.  
  951.  
  952. *------ Imported Names -----------------------------------------------
  953.  
  954.         XREF            _Init
  955.         XREF            _Expunge
  956.         XREF            _Open
  957.         XREF            _Close
  958.         XREF            _CommandTable
  959.         XREF            _PrinterSegmentData
  960.         XREF            _DoSpecial
  961.         XREF            _Render
  962.  
  963. *------ Exported Names -----------------------------------------------
  964.  
  965.         XDEF            _PEDData
  966.  
  967.  
  968. **********************************************************************
  969.  
  970.                 MOVEQ   #0,D0           ; show error for OpenLibrary()
  971.                 RTS
  972.                 DC.W    VERSION
  973.                 DC.W    REVISION
  974. _PEDData:
  975.                 DC.L    printerName
  976.                 DC.L    _Init
  977.                 DC.L    _Expunge
  978.                 DC.L    _Open
  979.                 DC.L    _Close
  980.                 DC.B    PPC_COLORGFX    ; PrinterClass
  981.                 DC.B    PCC_YMCB        ; ColorClass
  982.                 DC.B    80              ; MaxColumns
  983.                 DC.B    1               ; NumCharSets
  984.                 DC.W    4               ; NumRows
  985.                 DC.L    1024            ; MaxXDots
  986.                 DC.L    0               ; MaxYDots
  987.                 DC.W    120             ; XDotsInch
  988.                 DC.W    120             ; YDotsInch
  989.                 DC.L    _CommandTable   ; Commands
  990.                 DC.L    _DoSpecial
  991.                 DC.L    _Render
  992.                 DC.L    60              ; twice normal: slow alpha
  993.  
  994. printerName:
  995.                 STRING  <'Diablo C-150'>
  996.  
  997.                 END
  998.  
  999.  
  1000.  
  1001. /* diablo C-150 command table */
  1002.  
  1003. /****** printer.device/printers/Diablo_C-150_functions *****************
  1004.  *
  1005.  *   NAME
  1006.  *   Diablo C-150 functions implemented: 
  1007.  *  
  1008.  *      aRIS, aIND, aNEL,
  1009.  *      aSLPP, aLMS, aRMS,
  1010.  *      aHTS, aTBC0, aTBC3, aTBCALL, aTBSALL
  1011.  *
  1012.  *      special functions implemented:
  1013.  *      aRIN aSLRM aSFC
  1014.  *
  1015.  ************************************************************************/
  1016.  
  1017. char *CommandTable[]={
  1018.          "\033\015P",   /*reset              RIS      ESCc */
  1019.          "\377",        /*initialize*/
  1020.          "\012",        /* lf                IND      ESCD */
  1021.          "\015\012",    /* return,lf         NEL      ESCE */
  1022.          "\377",        /* reverse lf        RI       ESCM */
  1023.  
  1024.          "\377",        /*normal char set    SGR 0    ESC[0m */
  1025.          "\377",        /*italics on         SGR 3    ESC[3m */
  1026.          "\377",        /*italics off        SGR 23   ESC[23m */
  1027.          "\377",        /*underline on       SGR 4    ESC[4m */
  1028.          "\377",        /*underline off      SGR 24   ESC[24m */
  1029.          "\377",        /*boldface on        SGR 1    ESC[1m */
  1030.          "\377",        /*boldface off       SGR 22   ESC[22m */
  1031.          "\377",        /* set foreground color */
  1032.          "\377",        /* set background color */
  1033.  
  1034.          "\377",        /*normal space       DECSHORP ESC[0w */
  1035.          "\377",        /*elite on           DECSHORP ESC[2w */
  1036.          "\377",        /*elite off          DECSHORP ESC[1w */
  1037.          "\377",        /* fine on */
  1038.          "\377",        /* fine off */
  1039.          "\377",        /*enlarged on        GSM (special) */
  1040.          "\377",        /*enlarged off       GSM (special) */
  1041.  
  1042.          "\377",        /*shadow print on*/
  1043.          "\377",        /*shadow print off*/
  1044.          "\377",        /*doublestrike on*/
  1045.          "\377",        /*doublestrike off*/
  1046.          "\377",        /* NLQ on*/
  1047.          "\377",        /* NLQ off*/
  1048.  
  1049.          "\377",        /*superscript on     PLU      ESCL */
  1050.          "\377",        /*superscript off    PLD (special) */
  1051.          "\377",        /*subscript on       PLD      ESCK */
  1052.          "\377",        /*subscript off      PLU (special) */
  1053.      "\377",    /* normalize */
  1054.          "\377",        /* partial line up   PLU      ESCL */
  1055.          "\377",        /* partial line down PLD      ESCK */
  1056.  
  1057.          "\377",        /*US char set                 ESC(B */
  1058.          "\377",        /*French char set             ESC(R */
  1059.          "\377",        /*German char set             ESC(K */
  1060.          "\377",        /*UK char set                 ESC(A */
  1061.          "\377",        /*Danish I char set           ESC E */
  1062.          "\377",        /*Sweden char set             ESC(H */
  1063.          "\377",        /*Italian char set   FNT 6 */
  1064.          "\377",        /*Spanish char set   FNT 7 */
  1065.          "\377",        /*Japanese char set  FNT 8 */
  1066.          "\377",        /*Norweigen char set     FNT 9 */
  1067.          "\377",        /*Danish II char set*/
  1068.                               
  1069.          "\377",        /*proportional on */
  1070.          "\377",        /*proportional off*/
  1071.          "\377",        /*proportional clear*/
  1072.          "\377",        /*set prop offset    TSS */
  1073.          "\377",        /*auto left justify  JFY 5 */
  1074.          "\377",        /*auto right justify JFY 7 */
  1075.          "\377",        /*auto full justify  JFY 3,6 */
  1076.          "\377",        /*auto justify off   JFY 0 */
  1077.          "\377",        /*place holder */
  1078.          "\377",        /*auto center on     JFY 2,6 */
  1079.  
  1080.          "\377",        /* 1/8" line space   DECVERP  ESC[0z */
  1081.          "\377",        /* 1/6" line spacing DECVERP  ESC[1z */
  1082.          "\033\014",    /* set form length   DECSLPP  ESC[Pnt */
  1083.          "\377",        /* perf skip n */
  1084.          "\377",        /* perf skip off */
  1085.                         
  1086.          "\0339",       /* Left margin set   DECSLRM  ESC[Pn1;Pn2s */
  1087.          " \0330",       /* Right margin set */
  1088.          "\377",        /* Top margin set    DECSTBM  ESC[Pn1;Pn2r */
  1089.          "\377",        /* Bottom marg set */
  1090.          "\377",        /* T&B margin set   STBM      ESC[Pn1;Pn2r */
  1091.          "\377",        /* L&R margin set   SLRM      ESC[Pn1;Pn2s */
  1092.                 /* Clear margins */
  1093.          "\033l5\015\033r90\015",
  1094.  
  1095.          "\0331",       /* Set horiz tab     HTS      ESCH */
  1096.          "\377",        /* Set vertical tab  VTS      ESCJ */
  1097.          "\0338",       /* Clr horiz tab     TBC 0    ESC0g */
  1098.          "\0332",       /* Clear all h tabs  TBC 3    ESC3g */ 
  1099.          "\377",        /* Clr vertical tab  TBC 1    ESC1g */
  1100.          "\377",        /* Clr all v tabs    TBC 4    ESC4g */
  1101.          "\0332",       /* Clr all h & v tabs */
  1102.             /* set default tabs */
  1103.      "\033i9,17,25,33,41,49,57,65,73,81,89,97,105,113,121,129",
  1104.      "\377"     /* extended commands */
  1105.  
  1106. };
  1107.  
  1108.  
  1109.  
  1110. /* diablo C-150 special printer functions */
  1111.  
  1112. /****** printer.device/printers/Diablo_C-150_special_functions **********
  1113.  *
  1114.  *   NAME
  1115.  *   Diablo C-150 special functions implemented:
  1116.  * 
  1117.  ************************************************************************/
  1118.  
  1119. #include    "exec/types.h"
  1120. #include "../printer/printer.h"
  1121. #include "../printer/prtbase.h"
  1122.  
  1123. extern struct PrinterData *PD;
  1124.  
  1125. DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
  1126.    char outputBuffer[];
  1127.    UWORD *command;
  1128.  
  1129.    BYTE *vline;
  1130.    UBYTE *currentVMI; /* used for color on this printer */
  1131.    BYTE *crlfFlag;
  1132.    UBYTE Parms[];
  1133. {
  1134.     int x=0;
  1135.     int y=0;
  1136.     static BYTE ISOcolorTable[10]= {49,51,53,52,55,50,54,48,49,49};
  1137.     static unsigned char initMarg[]="\033l00\015\033r00\015";
  1138.  
  1139. if(*command==aRIN) {
  1140.    *currentVMI=0x70; /* white background, black text */
  1141.     outputBuffer[x++]='\015';
  1142.     outputBuffer[x++]='\012';
  1143.  
  1144.     Parms[0]=(PD->pd_Preferences.PrintLeftMargin);
  1145.     Parms[1]=(PD->pd_Preferences.PrintRightMargin);
  1146.     *command=aSLRM;
  1147. }
  1148. if(*command==aSLRM) {
  1149.     Parms[0]=Parms[0]+4;
  1150.     if(Parms[0]<5)Parms[0]=5;
  1151.  
  1152.     Parms[1]=Parms[1]+5;
  1153.     if(Parms[1]>90)Parms[1]=90;
  1154.  
  1155.     initMarg[2]=(char)((Parms[0]/10)+'0'); 
  1156.     initMarg[3]=(char)((Parms[0]-(UBYTE)(Parms[0]/10)*10)+'0');
  1157.     initMarg[7]=(char)((Parms[1]/10)+'0'); 
  1158.     initMarg[8]=(char)((Parms[1]-(UBYTE)(Parms[1]/10)*10)+'0');
  1159.     while(y<10)outputBuffer[x++]=initMarg[y++];
  1160.     return(x);
  1161. }
  1162. if(*command==aSFC)
  1163.     {
  1164. if(Parms[0]==39)Parms[0]=30; /* set defaults */
  1165. if(Parms[0]==49)Parms[0]=47;
  1166.  
  1167. if(Parms[0]<40) *currentVMI=((*currentVMI)&240)+(Parms[0]-30);
  1168. else *currentVMI=((*currentVMI)&15)+((Parms[0]-40)*16);
  1169.  
  1170.     outputBuffer[x++]='\033';
  1171.     outputBuffer[x++]='@';
  1172.     outputBuffer[x++]=ISOcolorTable[(*currentVMI)&15];
  1173.     outputBuffer[x++]=ISOcolorTable[(((*currentVMI)&240)/16)];
  1174.     return(x);
  1175.     }
  1176. return(0);
  1177. }
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187. /*********************************************************************/
  1188. #include <exec/types.h>
  1189. #include <exec/nodes.h>
  1190. #include <exec/lists.h>
  1191. #include <exec/memory.h>
  1192. #include "../printer/prtbase.h"
  1193.  
  1194. extern struct PrinterData *PD;
  1195.  
  1196. /* for the EPSON    */
  1197. int Render(ct, x, y, status, pc)
  1198.     UBYTE ct;   /* null for b/w printers */
  1199.     UWORD x, y; /* the x & y co-ordinates */
  1200.     UBYTE status;   /* print status (0-init, 1-enter pixel, 2-dump) */
  1201.     UWORD pc; /* the # of print columns (ie. pixels) */
  1202. {
  1203.     static UWORD ROWSIZE;
  1204.     static UWORD BUFSIZE;
  1205.     static UWORD bufptr;
  1206.     UWORD i;                    /* mics. var */
  1207.     BYTE err;               /* the error # */
  1208.  
  1209.     switch(status)
  1210.     {
  1211.     case 0 :    /* alloc memory for printer buffer */
  1212.         ROWSIZE=pc; /* row size required for EPSON */
  1213.         BUFSIZE=(6+ROWSIZE); /* buffer size required for EPSON */
  1214.         PD->pd_PrintBuf = (UBYTE *)
  1215.             AllocMem(BUFSIZE*2,MEMF_PUBLIC); /* alloc public mem */
  1216.         if (err=(PD->pd_PrintBuf == 0)) return(err);
  1217.         if (err=(*(PD->pd_PWrite))("\033@",2)) return(err); /* reset printer to power-up state */
  1218.         if (err=(*(PD->pd_PWrite))("\0331",2)) return(err); /* select 7/72 inch spacing */
  1219.         bufptr=0;
  1220.         return(0); /* flag all ok */
  1221.         break;
  1222.  
  1223.     case 1 :    /* put pixel in buffer */
  1224.         i = bufptr+x+4; /* calc which byte to use */
  1225.         PD->pd_PrintBuf[i] = PD->pd_PrintBuf[i] | (1 << (7-(y&7))); /* fill print buffer */
  1226.         return(0); /* flag all ok */
  1227.         break;
  1228.  
  1229.     case 2 : /* dump buffer to printer */
  1230.         if (err=(*(PD->pd_PWrite))(&(PD->pd_PrintBuf[bufptr]), BUFSIZE)) return(err);
  1231.         bufptr=BUFSIZE-bufptr;
  1232.         return(0); /* flag all ok */
  1233.         break;
  1234.  
  1235.     case 3 : /* clear and init buffer */
  1236.         for (i=bufptr; i<bufptr+BUFSIZE; i++)
  1237.             PD->pd_PrintBuf[i] = 0; /* clear buffer */
  1238.         PD->pd_PrintBuf[bufptr] = 27;
  1239.         PD->pd_PrintBuf[bufptr+1] = 'L';
  1240.         PD->pd_PrintBuf[bufptr+2] = ROWSIZE & 0xff;
  1241.         PD->pd_PrintBuf[bufptr+3] = ROWSIZE >> 8;
  1242.         PD->pd_PrintBuf[bufptr+BUFSIZE-2] = 10;
  1243.         PD->pd_PrintBuf[bufptr+BUFSIZE-1] = 13;
  1244.         return(0); /* flag all ok */
  1245.         break;
  1246.  
  1247.     case 4 : /* free the print buffer memory */
  1248.         err=(*(PD->pd_PWrite))("\033@",2); /* reset printer to power-up state */
  1249.         if (!err) err=(*(PD->pd_PBothReady))(); /* wait for both buffers to empty */
  1250.         FreeMem(PD->pd_PrintBuf,BUFSIZE*2); /* free print buffer's memory */
  1251.         return(err); /* return status */
  1252.         break;
  1253.     default: return(0);
  1254.     }
  1255. }
  1256. /*********************************************************************/
  1257.  
  1258.  
  1259.  
  1260.         TTL    '$Header: printertag.asm,v 1.1 85/10/09 23:57:27 kodiak Exp $'
  1261. **********************************************************************
  1262. *                                                                    *
  1263. *   Copyright 1985, Commodore-Amiga Inc.   All rights reserved.      *
  1264. *   No part of this program may be reproduced, transmitted,          *
  1265. *   transcribed, stored in retrieval system, or translated into      *
  1266. *   any language or computer language, in any form or by any         *
  1267. *   means, electronic, mechanical, magnetic, optical, chemical,      *
  1268. *   manual or otherwise, without the prior written permission of     *
  1269. *   Commodore-Amiga Incorporated, 983 University Ave. Building #D,   *
  1270. *   Los Gatos, California, 95030                                     *
  1271. *                                                                    *
  1272. **********************************************************************
  1273. *
  1274. *       printer device dependent code tag
  1275. *
  1276. *   Source Control
  1277. *   --------------
  1278. *   $Header: printertag.asm,v 1.1 85/10/09 23:57:27 kodiak Exp $
  1279. *
  1280. *   $Locker:  $
  1281. *
  1282. *   $Log:       printertag.asm,v $
  1283. *   Revision 1.1  85/10/09  23:57:27  kodiak
  1284. *   replace reference to pdata w/ prtbase
  1285. *   
  1286. *   Revision 1.0  85/10/09  23:57:21  kodiak
  1287. *   added to rcs for updating in version 1
  1288. *   
  1289. *   Revision 29.1  85/08/19  08:32:10  kodiak
  1290. *   flag a graphics printer, not BWALPHA
  1291. *   
  1292. *   Revision 29.0  85/08/19  08:31:06  kodiak
  1293. *   added to rcs for updating in version 29
  1294. *   
  1295. *   Revision 25.1  85/06/16  01:02:15  kodiak
  1296. *   *** empty log message ***
  1297. *   
  1298. *   Revision 25.0  85/06/15  06:40:00  kodiak
  1299. *   added to rcs
  1300. *   
  1301. *   Revision 25.0  85/06/13  18:53:36  kodiak
  1302. *   added to rcs
  1303. *   
  1304. *
  1305. **********************************************************************
  1306.  
  1307.         SECTION         printer
  1308.  
  1309. *------ Included Files -----------------------------------------------
  1310.  
  1311.         INCLUDE         "exec/types.i"
  1312.         INCLUDE         "exec/nodes.i"
  1313.         INCLUDE         "exec/strings.i"
  1314.  
  1315.         INCLUDE         "epson_rev.i"
  1316.  
  1317.         INCLUDE         "../printer/prtbase.i"
  1318.  
  1319.  
  1320. *------ Imported Names -----------------------------------------------
  1321.  
  1322.         XREF            _Init
  1323.         XREF            _Expunge
  1324.         XREF            _Open
  1325.         XREF            _Close
  1326.         XREF            _CommandTable
  1327.         XREF            _PrinterSegmentData
  1328.         XREF            _DoSpecial
  1329.         XREF            _Render
  1330.  
  1331. *------ Exported Names -----------------------------------------------
  1332.  
  1333.         XDEF            _PEDData
  1334.  
  1335.  
  1336. **********************************************************************
  1337.  
  1338.                 MOVEQ   #0,D0           ; show error for OpenLibrary()
  1339.                 RTS
  1340.                 DC.W    VERSION
  1341.                 DC.W    REVISION
  1342. _PEDData:
  1343.                 DC.L    printerName
  1344.                 DC.L    _Init
  1345.                 DC.L    _Expunge
  1346.                 DC.L    _Open
  1347.                 DC.L    _Close
  1348.                 DC.B    PPC_BWGFX       ; PrinterClass
  1349.                 DC.B    PCC_BW          ; ColorClass
  1350.                 DC.B    80              ; MaxColumns
  1351.                 DC.B    10              ; NumCharSets
  1352.                 DC.W    8               ; NumRows
  1353.                 DC.L    960             ; MaxXDots
  1354.                 DC.L    0               ; MaxYDots
  1355.                 DC.W    120             ; XDotsInch
  1356.                 DC.W    82              ; YDotsInch
  1357.                 DC.L    _CommandTable   ; Commands
  1358.                 DC.L    _DoSpecial
  1359.                 DC.L    _Render
  1360.                 DC.L    30
  1361.  
  1362. printerName:
  1363.                 STRING  <'Epson'>
  1364.  
  1365.                 END
  1366.  
  1367.  
  1368.  
  1369. /* epson X80 series */
  1370.  
  1371. /****** printer.device/printers/Epson_functions **************************
  1372.  *
  1373.  *   NAME
  1374.  *   Epson X-80 functions implemented: 
  1375.  *  
  1376.  *      aRIS, aIND, aNEL, aSGR0, aSGR3, aSGR23, aSGR4, aSGR24, aSGR1, aSGR22,
  1377.  *      aSHORP0, aSHORP1, aSHORP2, aSHORP3, aSHORP4, aSHORP5, aSHORP6,
  1378.  *      aDEN1, aDEN2, aDEN3, aDEN4,
  1379.  *      aSUS0, aSUS1, aSUS2, aSUS3, aSUS4,
  1380.  *      aFNT0, aFNT1, aFNT2, aFNT3, aFNT4, aFNT5, aFNT6, aFNT7, aFNT8
  1381.  *      aFNT9, aFNT10,
  1382.  *      aPROP1, aPROP2, aJFY5, aJFY7, aJFY6, aJFY0, aJFY3, aJFY2,
  1383.  *      aVERP0, aVERP1, aSLPP, aPERF, aPERF0,
  1384.  *      aTBC3, aTBC4, aTBCALL, aTBSALL
  1385.  *
  1386.  *   special functions implemented:
  1387.  *
  1388.  *      aRIN, aSUS0, aSUS1, aSUS2, aSUS3, aSUS4,
  1389.  *      aPLU, aPLD, aVERP0, aVERP1, aSLRM, aIND, aCAM
  1390.  *
  1391.  ************************************************************************/
  1392.  
  1393. char *CommandTable[] ={
  1394.          "\033@",       /*reset              RIS      ESCc */
  1395.          "\377",        /*initialize*/
  1396.          "\012",        /* lf                IND      ESCD */
  1397.          "\015\012",    /* return,lf         NEL      ESCE */
  1398.          "\377",        /* reverse lf        RI       ESCM */
  1399.  
  1400.                 /*normal char set    SGR 0    ESC[0m */
  1401.          "\0335\033-\376\033F",
  1402.          "\0334",       /*italics on         SGR 3    ESC[3m */
  1403.          "\0335",       /*italics off        SGR 23   ESC[23m */
  1404.          "\033-\001",   /*underline on       SGR 4    ESC[4m */
  1405.          "\033-\376",   /*underline off      SGR 24   ESC[24m */
  1406.          "\033E",       /*boldface on        SGR 1    ESC[1m */
  1407.          "\033F",       /*boldface off       SGR 22   ESC[22m */
  1408.          "\377",        /* set foreground color */
  1409.          "\377",        /* set background color */
  1410.  
  1411.             /* normal char set   SHORP    ESC[0w */
  1412.      "\033P\033\022\033W\376",
  1413.          "\033M",       /*elite on           SHORP    ESC[2w */
  1414.          "\033P",       /*elite off          SHORP    ESC[1w */
  1415.          "\017",        /*condensed(fine) on SHORP    ESC[4w */
  1416.          "\022",        /*condensed off      SHORP    ESC[3w */
  1417.          "\033W\001",   /*enlarged on        SHORP    ESC[6w */
  1418.          "\033W\376",   /*enlarged off       SHORP    ESC[5w */
  1419.  
  1420.          "\377",        /*shadow print on    DEN6     ESC[6"z */
  1421.          "\377",        /*shadow print off   DEN5     ESC[5"z */
  1422.          "\033G",       /*doublestrike on    DEN4     ESC[4"z */
  1423.          "\033H",       /*doublestrike off   DEN3     ESC[3"z */
  1424.          "\033x\001",   /* NLQ on            DEN2     ESC[2"z */
  1425.          "\033x\376",   /* NLQ off       DEN1     ESC[1"z */
  1426.  
  1427.          "\033S\376",   /*superscript on              ESC[2u */
  1428.          "\033T",       /*superscript off         ESC[1u */
  1429.          "\033S\001",   /*subscript on            ESC[4u */
  1430.          "\033T",       /*subscript off           ESC[3u */
  1431.      "\033T",   /*normalize           ESC[0u */
  1432.          "\377",        /* partial line up   PLU      ESCL */
  1433.          "\377",        /* partial line down PLD      ESCK */
  1434.  
  1435.          "\033R\376",   /*US char set        FNT0     ESC(B */
  1436.          "\033R\001",   /*French char set    FNT1     ESC(R */
  1437.          "\033R\002",   /*German char set    FNT2     ESC(K */
  1438.          "\033R\003",   /*UK char set        FNT3     ESC(A */
  1439.          "\033R\004",   /*Danish I char set  FNT4     ESC E */
  1440.          "\033R\005",   /*Sweden char set    FNT5     ESC(H */
  1441.          "\033R\006",   /*Italian char set   FNT6     ESC(Y */
  1442.          "\033R\007",   /*Spanish char set   FNT7     ESC(Z */
  1443.          "\033R\010",   /*Japanese char set  FNT8     ESC(J */
  1444.          "\033R\011",   /*Norweign char set  FNT9     ESC(6 */
  1445.          "\033R\012",   /*Danish II char set FNT10    ESC(C */
  1446.                               
  1447.          "\033p\001",   /*proportional on    PROP     ESC[2p */
  1448.          "\033p\376",   /*proportional off   PROP     ESC[1p */
  1449.          "\377",        /*proportional clear PROP     ESC[0p */
  1450.          "\377",        /*set prop offset    TSS */
  1451.          "\033a\376",   /*auto left justify  JFY5     ESC[5 F */
  1452.          "\033a\002",   /*auto right justify JFY7     ESC[7 F */
  1453.          "\033a\003",   /*auto full justify  JFY6     ESC[6 F */
  1454.          "\033x\376",   /*auto justify/center off   ESC[0 F */
  1455.          "\377",        /*place holder       JFY3     ESC[3 F */
  1456.          "\033a\001",   /*auto center on     JFY2     ESC[2 F */
  1457.  
  1458.          "\0330",       /* 1/8" line space   VERP     ESC[0z */
  1459.          "\0332",       /* 1/6" line spacing VERP     ESC[1z */
  1460.          "\033C",       /* set form length   SLPP     ESC[Pnt */
  1461.          "\033N",       /* perf skip n            ESC[nq */
  1462.          "\033O",       /* perf skip off              ESC[0q */
  1463.                         
  1464.          "\377",        /* Left margin set            ESC[2x */
  1465.          "\377",        /* Right margin set           ESC[3x */
  1466.          "\377",        /* top margin set         ESC[4x */
  1467.          "\377",        /* Bottom marg set        ESC[5x */
  1468.          "\377",        /* T&B margin set   STBM      ESC[Pn1;Pn2r */
  1469.          "\377",        /* L&R margin set   SLRM      ESC[Pn1;Pn2s */
  1470.          "\377",        /* Clear margins          ESC[0x */
  1471.  
  1472.          "\377",    /* Set horiz tab     HTS      ESCH */
  1473.  
  1474.          "\377",        /* Set vertical tab  VTS      ESCJ */
  1475.  
  1476.          "\377",    /* Clr horiz tab     TBC 0    ESC[0g */
  1477.  
  1478.             /* Clear all h tabs  TBC 3    ESC[3g */ 
  1479.          "\377",    /* "\033D\376", */
  1480.  
  1481.          "\377",        /* Clr vertical tab  TBC 1    ESC[1g */
  1482.  
  1483.             /* Clr all v tabs    TBC 4    ESC[4g */
  1484.          "\377",    /* "\033B\376", */
  1485.  
  1486.                 /* Clr all h & v tabs         ESC#4 */
  1487.          "\377",    /*"\033D\376\033B\376", */
  1488.  
  1489.      "\377",    /* set default tabs */
  1490.             /* "\033D\011\021\031\041\051\061\071\101\111\121\131\376", */
  1491.  
  1492.      "\377"     /* entended command */
  1493.  
  1494.  
  1495. };
  1496.  
  1497.  
  1498.  
  1499. /* epson X80 special commands */
  1500.  
  1501. /****** printer.device/printers/Epson_special_functions ******************
  1502.  *
  1503.  *   NAME
  1504.  *   Epson X80 special functions
  1505.  * 
  1506.  ************************************************************************/
  1507.  
  1508. #include    "exec/types.h"
  1509. #include "../printer/printer.h"
  1510. #include "../printer/prtbase.h"
  1511.  
  1512. extern struct PrinterData *PD;
  1513.  
  1514. DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
  1515.    char outputBuffer[];
  1516.    UWORD *command;
  1517.    BYTE *vline;
  1518.    BYTE *currentVMI;
  1519.    BYTE *crlfFlag;
  1520.    UBYTE Parms[];
  1521.  
  1522. {
  1523.    int x=0;
  1524.    int y=0;
  1525.    static char initMarg[]="\033lL\033Qq\033Q\120\033Q\210\033Q\240";
  1526. static char
  1527.     initThisPrinter[]="\033x\001\0332\033\022\0335\033P\033-\376\033F\n\033W";
  1528.  
  1529.  
  1530. if(*command==aRIN) {
  1531.     while(x<19){outputBuffer[x]=initThisPrinter[x];x++;}
  1532.     outputBuffer[x++]='\000';
  1533.     outputBuffer[13]='\000';
  1534.  
  1535.     if((PD->pd_Preferences.PrintQuality)==DRAFT)outputBuffer[2]='\000';
  1536.  
  1537.     *currentVMI=36; /* assume 1/6 line spacing */
  1538.     if((PD->pd_Preferences.PrintSpacing)==EIGHT_LPI) { /* wrong again */
  1539.     outputBuffer[4]='0';
  1540.     *currentVMI=27;
  1541.     }
  1542.     if ((PD->pd_Preferences.PrintPitch) != PICA)outputBuffer[x++]='\033';
  1543.     if((PD->pd_Preferences.PrintPitch)==ELITE)outputBuffer[x++]='M';
  1544.     else if((PD->pd_Preferences.PrintPitch)==FINE)
  1545.     outputBuffer[x++]='\017';
  1546.  
  1547.     Parms[0]=(PD->pd_Preferences.PrintLeftMargin);
  1548.     Parms[1]=(PD->pd_Preferences.PrintRightMargin);
  1549.     *command=aSLRM;
  1550. }
  1551.  
  1552. if(*command==aSLRM) {
  1553.     initMarg[2]=Parms[0];
  1554.     initMarg[5]=Parms[1]+1;
  1555.     while(y<6)outputBuffer[x++]=initMarg[y++];
  1556.     return(x);
  1557. }
  1558.  
  1559. if(*command==aCAM) {
  1560.     initMarg[2]=1;
  1561.     initMarg[5]=80;
  1562.     while(y<15)outputBuffer[x++]=initMarg[y++];
  1563.     return(x);
  1564. }
  1565.  
  1566. if(*command==aPLU) {
  1567.     if((*vline)==0){(*vline)=1; *command=aSUS2; return(0);}
  1568.     if((*vline)<0){(*vline)=0; *command=aSUS3; return(0);}
  1569.     return(-1);
  1570. }
  1571.  
  1572. if(*command==aPLD) {
  1573.     if((*vline)==0){(*vline)=(-1); *command=aSUS4; return(0);}
  1574.     if((*vline)>0){(*vline)=0; *command=aSUS1; return(0);}
  1575.     return(-1);
  1576. }
  1577.  
  1578. if(*command==aSUS0) *vline=0;
  1579. if(*command==aSUS1) *vline=0;
  1580. if(*command==aSUS2) *vline=1;
  1581. if(*command==aSUS3) *vline=0;
  1582. if(*command==aSUS4) *vline=(-1);
  1583.  
  1584. if(*command==aVERP0) *currentVMI=27;
  1585.  
  1586. if(*command==aVERP1) *currentVMI=36;
  1587.  
  1588. if(*command==aIND) {
  1589.     outputBuffer[x++]='\033';
  1590.     outputBuffer[x++]='J';
  1591.     outputBuffer[x++]= *currentVMI;
  1592.     return(x);
  1593. }
  1594.  
  1595. return(0);
  1596. }
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603. /*********************************************************************/
  1604. #include <exec/types.h>
  1605. #include <exec/nodes.h>
  1606. #include <exec/lists.h>
  1607. #include <exec/memory.h>
  1608. #include "../printer/prtbase.h"
  1609. #include "../printer/printer.h"
  1610.  
  1611. extern struct PrinterData *PD;
  1612. extern struct PrinterExtendedData *PED;
  1613. extern SetDensity();
  1614. char density[8] = "\033*t100R";
  1615.  
  1616. /* for the HP+ 2686A */
  1617. int Render(ct, x, y, status, pc)
  1618.     UBYTE ct;               /* null for b/w printers */
  1619.     UWORD x, y;             /* the x & y co-ordinates */
  1620.     UBYTE status;           /* print status (0-init, 1-enter pixel, 2-dump, 3-close, 4-end) */
  1621.     UWORD pc;               /* the # of print columns (ie. pixels) */
  1622. {
  1623.     static UWORD ROWSIZE;
  1624.     static UWORD BUFSIZE;
  1625.     static BYTE huns,tens,ones; /* used to program buffer size */
  1626.     static UWORD bufptr; /* used for double buffering; points to buffer 1 or 2 */
  1627.     UWORD i;                    /* mics. var */
  1628.     BYTE err;               /* the error # */
  1629.  
  1630. #ifdef  DEBUG
  1631. kprintf("hp render(%ld, %ld, %ld, %ld, %ld);\n", ct, x, y, status, pc);
  1632. #endif
  1633.     switch(status)
  1634.     {
  1635.     case 0 :    /* alloc memory for printer buffer (uses double buffering) */
  1636.         ROWSIZE=(pc+7)/8; /* row size required for HP */
  1637.         huns=ROWSIZE/100;
  1638.         tens=(ROWSIZE-huns*100)/10;
  1639.         ones=(ROWSIZE-huns*100-tens*10);
  1640.         BUFSIZE=(ROWSIZE+7); /* buffer size required for HP */
  1641.         PD->pd_PrintBuf = (UBYTE *)
  1642.             AllocMem(BUFSIZE*2,MEMF_PUBLIC); /* alloc public mem */
  1643.         if (err=(PD->pd_PrintBuf == 0)) return(err);
  1644.         if (err=(*(PD->pd_PWrite))("\033E",2)) return(err); /* reset printer */
  1645.         if (err=(*(PD->pd_PWrite))(density,7)) return(err); /* set resolution */
  1646.         if (err=(*(PD->pd_PWrite))("\033*r0A",5)) return(err); /* start raster gfx */
  1647.         bufptr=0; /* init to first buffer */
  1648.         return(0); /* flag all ok */
  1649.         break;
  1650.  
  1651.     case 1 :    /* put pixel in buffer */
  1652.         i = bufptr+x/8+7; /* calc which byte to use */
  1653.         PD->pd_PrintBuf[i] = PD->pd_PrintBuf[i] | (1 << (7-(x&7))); /* fill print buffer */
  1654.         return(0); /* flag all ok */
  1655.         break;
  1656.  
  1657.     case 2 : /* dump buffer to printer */
  1658.         if (err=(*(PD->pd_PWrite))(&(PD->pd_PrintBuf[bufptr]), BUFSIZE)) return(err);
  1659.         bufptr=BUFSIZE-bufptr; /* switch to other buffer */
  1660.         return(0); /* flag all ok */
  1661.         break;
  1662.  
  1663.     case 3 : /* clear and init buffer */
  1664.         for (i=bufptr; i<BUFSIZE+bufptr; i++)
  1665.             PD->pd_PrintBuf[i] = 0; /* clear buffer */
  1666.         PD->pd_PrintBuf[bufptr] = 27;
  1667.         PD->pd_PrintBuf[bufptr+1] = '*';
  1668.         PD->pd_PrintBuf[bufptr+2] = 'b';
  1669.         PD->pd_PrintBuf[bufptr+3] = huns + '0';
  1670.         PD->pd_PrintBuf[bufptr+4] = tens + '0';
  1671.         PD->pd_PrintBuf[bufptr+5] = ones + '0';
  1672.         PD->pd_PrintBuf[bufptr+6] = 'W';
  1673.         return(0); /* flag all ok */
  1674.         break;
  1675.  
  1676.     case 4 : /* free the print buffer memory */
  1677. /* end raster graphics, unload paper, and reset printer */
  1678.         err=(*(PD->pd_PWrite))("\033*rB\014\033E",7);
  1679.         if (!err) err=(*(PD->pd_PBothReady))(); /* wait for both buffers to be clear */
  1680.         FreeMem(PD->pd_PrintBuf,BUFSIZE*2); /* free the print buffers memory */
  1681.         return(err); /* return status */
  1682.         break;
  1683.  
  1684.     case 5:
  1685.         if ((pc & SPECIAL_DENSITYMASK) == 0) { /* if use prefs */
  1686.             if (PD->pd_Preferences.PrintQuality == DRAFT)
  1687.                 SetDensity(SPECIAL_DENSITY2); /* 100 dpi */
  1688.             else SetDensity(SPECIAL_DENSITY3); /* 150 dpi */
  1689.         }
  1690.         else SetDensity(pc & SPECIAL_DENSITYMASK); /* else use SPECIAL */
  1691.         return(0);
  1692.         break;
  1693.  
  1694.     default :
  1695.         return(0);
  1696.         break;
  1697.     }
  1698. }
  1699.  
  1700. /*********************************************************************/
  1701.  
  1702.  
  1703.  
  1704.         TTL    '$Header: printertag.asm,v 1.2 85/10/09 23:58:23 kodiak Exp $'
  1705. **********************************************************************
  1706. *                                                                    *
  1707. *   Copyright 1985, Commodore-Amiga Inc.   All rights reserved.      *
  1708. *   No part of this program may be reproduced, transmitted,          *
  1709. *   transcribed, stored in retrieval system, or translated into      *
  1710. *   any language or computer language, in any form or by any         *
  1711. *   means, electronic, mechanical, magnetic, optical, chemical,      *
  1712. *   manual or otherwise, without the prior written permission of     *
  1713. *   Commodore-Amiga Incorporated, 983 University Ave. Building #D,   *
  1714. *   Los Gatos, California, 95030                                     *
  1715. *                                                                    *
  1716. **********************************************************************
  1717. *
  1718. *       printer device dependent code tag
  1719. *
  1720. *   Source Control
  1721. *   --------------
  1722. *   $Header: printertag.asm,v 1.2 85/10/09 23:58:23 kodiak Exp $
  1723. *
  1724. *   $Locker:  $
  1725. *
  1726. *   $Log:       printertag.asm,v $
  1727. *   Revision 1.2  85/10/09  23:58:23  kodiak
  1728. *   replace reference to pdata w/ prtbase
  1729. *   
  1730. *   Revision 1.1  85/10/09  16:11:31  kodiak
  1731. *   daveb density changes
  1732. *   
  1733. *   Revision 25.1  85/06/16  01:02:15  kodiak
  1734. *   *** empty log message ***
  1735. *   
  1736. *   Revision 25.0  85/06/15  06:40:00  kodiak
  1737. *   added to rcs
  1738. *   
  1739. *   Revision 25.0  85/06/13  18:53:36  kodiak
  1740. *   added to rcs
  1741. *   
  1742. *
  1743. **********************************************************************
  1744.  
  1745.         SECTION         printer
  1746.  
  1747. *------ Included Files -----------------------------------------------
  1748.  
  1749.         INCLUDE         "exec/types.i"
  1750.         INCLUDE         "exec/nodes.i"
  1751.         INCLUDE         "exec/strings.i"
  1752.  
  1753.         INCLUDE         "hpplus_rev.i"
  1754.  
  1755.         INCLUDE         "../printer/prtbase.i"
  1756.  
  1757.  
  1758. *------ Imported Names -----------------------------------------------
  1759.  
  1760.         XREF            _Init
  1761.         XREF            _Expunge
  1762.         XREF            _Open
  1763.         XREF            _Close
  1764.         XREF            _CommandTable
  1765.         XREF            _PrinterSegmentData
  1766.         XREF            _DoSpecial
  1767.         XREF            _Render
  1768.  
  1769. *------ Exported Names -----------------------------------------------
  1770.  
  1771.         XDEF            _PEDData
  1772.  
  1773.  
  1774. **********************************************************************
  1775.  
  1776.                 MOVEQ   #0,D0           ; show error for OpenLibrary()
  1777.                 RTS
  1778.                 DC.W    VERSION
  1779.                 DC.W    REVISION
  1780. _PEDData:
  1781.                 DC.L    printerName
  1782.                 DC.L    _Init
  1783.                 DC.L    _Expunge
  1784.                 DC.L    _Open
  1785.                 DC.L    _Close
  1786.                 DC.B    PPC_BWGFX       ; PrinterClass
  1787.                 DC.B    PCC_BW          ; ColorClass
  1788.                 DC.B    0               ; MaxColumns
  1789.                 DC.B    0               ; NumCharSets
  1790.                 DC.W    1               ; NumRows
  1791.                 DC.L    800     ; MaxXDots
  1792.                 DC.L    1020    ; MaxYDots
  1793.                 DC.W    100     ; XDotsInch
  1794.                 DC.W    100     ; YDotsInch
  1795.                 DC.L    _CommandTable   ; Commands
  1796.                 DC.L    _DoSpecial
  1797.                 DC.L    _Render
  1798.                 DC.L    30
  1799.  
  1800. printerName:
  1801.                 STRING  <'HP LaserJet Plus'>
  1802.  
  1803.                 END
  1804.  
  1805.  
  1806. /* HP command table */
  1807.  
  1808. /****** printer.device/HP_LaserJet_Plus_functions ************************
  1809.  *
  1810.  *   NAME
  1811.  *   HP LaserJet 2686A functions implemented: 
  1812.  *  
  1813.  *      aRIS, aIND, aNEL, 
  1814.  *      aSGR0, aSGR3, aSGR23, aSGR4, aSGR24, aSGR1, aSGR22,
  1815.  *      aSHORP0, aSHORP1, aSHORP2, aSHORP3, aSHORP4
  1816.  *      aDEN3, aDEN4, aPLU, aPLD,
  1817.  *      aFNT0, aFNT3, aFNT8,
  1818.  *      aPROP0, aPROP1, aPROP2,
  1819.  *      aVERP0, aVERP1, aPERF, aPERF0, aCAM
  1820.  *
  1821.  ************************************************************************/
  1822.  
  1823. char *CommandTable[]={
  1824.          "\033E",       /*reset*/
  1825.          "\377",        /*initialize*/  
  1826.          "\012",        /* lf                IND      ESCD */
  1827.          "\015\012",    /* return,lf         NEL      ESCE */
  1828.          "\033&a-1R",
  1829.                 /* reverse lf        RI       ESCM */
  1830.  
  1831.     "\033&d@\033(sbS",  /*normal char set    SGR 0 */
  1832.          "\033(s1S",        /*italics on*/
  1833.          "\033(sS",        /*italics off*/
  1834.          "\033&dD",       /*underline on*/
  1835.          "\033&d@",       /*underline off */
  1836.          "\033(s3B",       /*boldface on*/
  1837.          "\033(sB",       /*boldface off*/
  1838.          "\377",        /* set foreground color */
  1839.          "\377",        /* set background color */
  1840.  
  1841.          "\033(s10h1T",     /* normal pitch */
  1842.          "\033(s12h2T",     /* elite on*/
  1843.          "\033(s10h1T",     /* elite off*/
  1844.          "\033(s15H",/* condensed on*/
  1845.          "\033(s10H",/* condensed off*/
  1846.          "\377",        /* enlarged on*/
  1847.          "\377",        /* enlarged off*/
  1848.  
  1849.          "\033(s7B",    /*shadow print on*/
  1850.          "\033(sB", /*shadow print off*/
  1851.          "\033(s3B",    /*doublestrike on*/
  1852.          "\033(sB", /*doublestrike off*/
  1853.          "\377",        /* NLQ on*/
  1854.          "\377",        /* NLQ off*/
  1855.  
  1856.          "\377",        /*superscript on*/
  1857.          "\377",        /*superscript off*/
  1858.          "\377",        /*subscript on*/
  1859.          "\377",        /*subscript off*/
  1860.      "\377",    /* normalize */
  1861.          "\033&a-.5R",  /* partial line up   PLU      ESCL */
  1862.          "\033=",   /* partial line down PLD      ESCK */
  1863.  
  1864.  
  1865.          "\033(U",  /*US char set */
  1866.          "\033(F",  /*French char set*/
  1867.          "\033(G",  /*German char set*/
  1868.          "\033(1E", /*UK char set*/
  1869.          "\033(D",  /*Danish I char set*/
  1870.          "\033(S",  /*Sweden char set*/
  1871.          "\033(I",  /*Italian char set*/
  1872.          "\033(1S", /*Spanish char set*/
  1873.          "\033(8K", /*Japanese char set*/
  1874.          "\033(D",  /*Norweigen char set*/
  1875.          "\033(D",  /*Danish II char set*/
  1876.                               
  1877.          "\033(s1P",    /*proportional on*/
  1878.          "\033(sP", /*proportional off*/
  1879.          "\033(sP", /*proportional clear*/
  1880.          "\377",    /*set prop offset*/
  1881.          "\377",    /*auto left justify on*/
  1882.          "\377",    /*auto right justify on*/
  1883.          "\377",    /*auto full justify on*/
  1884.          "\377",    /*auto justify/center off*/
  1885.          "\377",    /*place holder */
  1886.          "\377",    /*auto center on*/
  1887.  
  1888.          "\033&l8D",    /* 1/8" line space*/
  1889.          "\033&l6D",    /* 1/6" line spacing*/
  1890.          "377",     /* set form length n */
  1891.          "\033&l1L",    /* perf skip n */
  1892.          "\033&lL",    /* Perf skip off */
  1893.                         
  1894.          "\0334",   /* Left margin set */
  1895.          "\0335",   /* Right margin set */
  1896.          "\377",    /* Top margin set */
  1897.          "\377",    /* Bottom marg set */
  1898.          "\377",    /* T&B margin set   STBM      ESC[Pn1;Pn2r */
  1899.          "\377",    /* L&R margin set   SLRM      ESC[Pn1;Pn2s */
  1900.          "\0339",   /* Clear margins */
  1901.  
  1902.          "\0331",   /* Set horiz tab */
  1903.          "\377",    /* Set vertical tab */
  1904.          "\0332",   /* Clr horiz tab */
  1905.          "\0333",   /* Clear all h tabs */ 
  1906.          "\377",    /* Clear vertical tab */
  1907.          "\377",    /* Clr all v tabs    TBC 4 */
  1908.          "\377",    /* Clr all h & v tabs */
  1909.      "\377",    /* set default tabs */
  1910.      "\377"     /* extended commands */
  1911. };
  1912.  
  1913.  
  1914.  
  1915. /* hp special printer functions */
  1916.  
  1917. /****** printer.device/printers/HP_LaserJet_Plus_special_functions *******
  1918.  *
  1919.  *   NAME
  1920.  *   HP LaserJet 2686A special functions implemented:
  1921.  * 
  1922.  *      aRIN,
  1923.  *      aSUS0, aSUS1, aSUS2, aSUS3, aSUS4
  1924.  *      aPLU, aPLD, aVERP0, aVERP1,
  1925.  *      aSLPP, aSLRM, aSTBM
  1926.  *       
  1927.  ************************************************************************/
  1928.  
  1929. #include    "exec/types.h"
  1930. #include "../printer/printer.h"
  1931. #include "../printer/prtbase.h"
  1932.  
  1933. extern struct PrinterData *PD;
  1934.  
  1935.  
  1936. DoSpecial(command,outputBuffer,vline,currentVMI,crlfFlag,Parms)
  1937.    char outputBuffer[];
  1938.    UWORD *command;
  1939.    BYTE *vline;
  1940.    BYTE *currentVMI;
  1941.    BYTE *crlfFlag;
  1942.    UBYTE Parms[];
  1943. {
  1944.     int x=0;
  1945.     int y=0;
  1946.     int j=0;
  1947.     static char initThisPrinter[]="\033&d@\033&l6D\033(sb10hps1tu12V";
  1948.     static char initMarg[]="\033&a000l000M";
  1949.     static char initTMarg[]="\033&l000e000F";
  1950.     static char initForm[]="\033&l000P";
  1951.  
  1952. if(*command==aRIN) {
  1953.     while(x<24){outputBuffer[x]=initThisPrinter[x];x++;}
  1954.     if((PD->pd_Preferences.PrintSpacing)==EIGHT_LPI) { /* wrong again */
  1955.     outputBuffer[7]='8';
  1956.     }
  1957.  
  1958.     if((PD->pd_Preferences.PrintPitch)==ELITE) {
  1959.     outputBuffer[14]='2';
  1960.     outputBuffer[18]='2';
  1961.     }
  1962.     if((PD->pd_Preferences.PrintPitch)==FINE) {
  1963.     outputBuffer[14]='5';
  1964.     }
  1965.  
  1966.     Parms[0]=(PD->pd_Preferences.PrintLeftMargin);
  1967.     Parms[1]=(PD->pd_Preferences.PrintRightMargin);
  1968.     *command=aSLRM;
  1969. }
  1970. if(*command==aSLRM) {
  1971.     j=x;
  1972.         while(y<11)outputBuffer[x++]=initMarg[y++];
  1973.         numberString(Parms[0]-1,j+3,outputBuffer);
  1974.         numberString(Parms[1]-1,j+7,outputBuffer);
  1975.         return(x);
  1976. }
  1977.  
  1978. if((*command==aSUS2)&&(*vline==0)) {*command=aPLU; *vline=1; return(0);}
  1979. if((*command==aSUS2)&&(*vline<0)) {*command=aRI; *vline=1; return(0);}
  1980. if((*command==aSUS1)&&(*vline>0)) {*command=aPLD; *vline=0; return(0);}
  1981.  
  1982. if((*command==aSUS4)&&(*vline==0)) {*command=aPLD; *vline=(-1); return(0);}
  1983. if((*command==aSUS4)&&(*vline>0)) {*command=aIND; *vline=(-1); return(0);}
  1984. if((*command==aSUS3)&&(*vline<0)) {*command=aPLU; *vline=0; return(0);}
  1985.  
  1986. if(*command==aSUS0)
  1987.     {
  1988.     if(*vline>0) *command=aPLD;
  1989.     if(*vline<0) *command=aPLU;
  1990.     *vline=0;
  1991.     return(0);
  1992.     }
  1993.  
  1994. if(*command==aPLU){(*vline)++; return(0);}
  1995.  
  1996. if(*command==aPLD){(*vline)--; return(0);}
  1997.  
  1998. if(*command==aSTBM)
  1999.         {
  2000.         while(x<11){outputBuffer[x]=initTMarg[x]; x++;}
  2001.         numberString(Parms[0],3,outputBuffer);
  2002.         numberString(Parms[1]-Parms[0],7,outputBuffer);
  2003.         return(x);
  2004.     }
  2005.  
  2006. if(*command==aSLPP) {
  2007.         while(x<7){outputBuffer[x]=initForm[x]; x++;}
  2008.     numberString(Parms[0],3,outputBuffer);
  2009.     return(x);  
  2010.     }
  2011.  
  2012. return(0);
  2013. }
  2014.  
  2015. VOID
  2016. numberString(Param,x,outputBuffer)
  2017.    BYTE Param;
  2018.    int x;
  2019.    char outputBuffer[];
  2020. {
  2021.  
  2022. if(Param>199){outputBuffer[x++]='2'; Param-=200;}
  2023.    else if(Param>99){outputBuffer[x++]='1'; Param-=100;}
  2024.    else outputBuffer[x++]='0'; /* always return 3 digits */
  2025.  
  2026. if(Param>9)outputBuffer[x++]=(BYTE)(Param/10)+'0';
  2027.    else outputBuffer[x++]='0';
  2028.  
  2029. outputBuffer[x++]=Param%10+'0';
  2030. }
  2031.  
  2032. Close()
  2033. {
  2034. (*(PD->pd_PWrite))("\033E",2);
  2035. (*(PD->pd_PBothReady))(); 
  2036. return(0);
  2037. }
  2038.  
  2039.  
  2040.  
  2041.  
  2042. /*
  2043. ***** density.c *****
  2044. */
  2045. #include <exec/types.h>
  2046. #include "../printer/prtbase.h"
  2047. #include "../printer/printer.h"
  2048.  
  2049. extern struct PrinterExtendedData *PED;
  2050. extern char density[];
  2051.  
  2052. SetDensity(level)
  2053. UWORD level;
  2054. {
  2055.     switch (level) {
  2056.     case SPECIAL_DENSITY1:
  2057.         PED->ped_MaxXDots = 600;
  2058.         PED->ped_MaxYDots = 795;
  2059.         PED->ped_XDotsInch = PED->ped_YDotsInch = 75;
  2060.         density[3] = '0';
  2061.         density[4] = '7';
  2062.         density[5] = '5';
  2063.         break;
  2064.  
  2065.     case SPECIAL_DENSITY2:
  2066.         PED->ped_MaxXDots = 800;
  2067.         PED->ped_MaxYDots = 1060;
  2068.         PED->ped_XDotsInch = PED->ped_YDotsInch = 100;
  2069.         density[3] = '1';
  2070.         density[4] = '0';
  2071.         density[5] = '0';
  2072.         break;
  2073.  
  2074.     case SPECIAL_DENSITY3:
  2075.         PED->ped_MaxXDots = 1200;
  2076.         PED->ped_MaxYDots = 1590;
  2077.         PED->ped_XDotsInch = PED->ped_YDotsInch = 150;
  2078.         density[3] = '1';
  2079.         density[4] = '5';
  2080.         density[5] = '0';
  2081.         break;
  2082.  
  2083.     case SPECIAL_DENSITY4:
  2084.         PED->ped_MaxXDots = 2400;
  2085.         PED->ped_MaxYDots = 3180;
  2086.         PED->ped_XDotsInch = PED->ped_YDotsInch = 300;
  2087.         density[3] = '3';
  2088.         density[4] = '0';
  2089.         density[5] = '0';
  2090.         break;
  2091.  
  2092.     default: break;
  2093.     }
  2094. }
  2095. /*********************************************************************/
  2096.  
  2097.